package com.health.controller.backend;

import com.health.common.PageBean;
import com.health.common.PageQueryDTO;
import com.health.common.Result;
import com.health.domain.CheckItem;
import com.health.service.CheckitemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/checkitem")
@Slf4j
public class CheckitemController {

    @Autowired
    private CheckitemService checkitemService;

    @PostMapping("/findPage")
    public PageBean<CheckItem> findPage(@RequestBody PageQueryDTO pageQueryDTO) {
        log.warn("{}", pageQueryDTO);
        return checkitemService.findPage(pageQueryDTO);
    }

    @GetMapping("/findById")
    public Result findById(@RequestParam("id") Integer id){
        CheckItem checkItem = checkitemService.findById(id);

        return new Result(true,"查询检查项成功",checkItem);
    }

    @PostMapping("/edit")
    public Result updateById(@RequestBody CheckItem checkItem){
        checkitemService.updateById(checkItem);
        return new Result(true,"编辑检查项成功",null);
    }

    @GetMapping("/findAll")
    public Result<List<CheckItem>> findAll(){
        List<CheckItem> checkItemList = checkitemService.findAll();

        return new Result<>(true,"查询检查成功",checkItemList);
    }


}
